#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
void solve()
{
    ll n,c;
    cin >> n >> c;
    map<ll, ll> mp;
    vector<ll> a(n);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        mp[a[i]]++;
        a[i] -= c;
    }
    // a-b=c;
    // a-c=b;
    ll ans=0;
    for (ll i = 0; i <= n; i++)
        ans += mp[a[i]];
    cout << ans << endl;
}
int main()
{
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
